package controller;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import commons.Constants;

import model.PandaQuery;
import model.Picture;



import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;



public class PandaAction extends ActionSupport implements SessionAware{

	private Map session;
	private String pandaName;
	private List<Picture> pandaList;
	
	public void setSession(Map<String, Object> arg0) {
		this.session=arg0;
	}

	
	public List<Picture> getPandaList() {
		return pandaList;
	}

	public void setPandaList(List<Picture> pandaList) {
		this.pandaList = pandaList;
	}


	public String getPandaName() {
		return pandaName;
	}

	public void setPandaName(String pandaName) {
		this.pandaName = pandaName;
	}
	
	public String listPandaPictures(){
		System.out.println("Hago algo!!!!!!!"+pandaName);
		PandaQuery p=new PandaQuery();
		List<Picture> pandaList=p.callPanda(pandaName);
		session.put(Constants.PICTURE_LIST, pandaList);
		return SUCCESS;
	}	
	
	public String loadList(){
		Object obj = session.get(Constants.PICTURE_LIST);
		pandaList=(ArrayList<Picture>) obj;
		if (obj == null){
			return Constants.NO_PANDAS;
		}else{
			return SUCCESS;
		}
	}

}
